app.controller('loginController', ['$scope','ajax','$state','$sessionStorage','Flash',function ($scope,ajax,$state,$sessionStorage,Flash) {
    if($sessionStorage.username) $state.go("admin.welcome");
    $scope.login = function(username,password){
        ajax.post({
            data:{
                'username': username,
                'password': password
            },
            url: 'back/login'
        }).then(function (result) {
            $sessionStorage.username = result.username;
            Flash.create('success', result.username+'用户登录成功', 'custom-class');
            $state.go("admin.welcome");
        })
    }
}])